﻿<template>
	<div style="padding:0px;">
		<el-form :model="dialogForm" :rules="rules" ref="dialogForm" :label-width="formLabelWidth">
		<el-card class="box-card">
		  
		  <div  class="text item">
			
			  	<el-form-item label="订单号" >
			      <el-input v-model="dialogForm.qcsl" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="经销商名称" >
			      <el-input v-model="dialogForm.qckx" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="汽车车型" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="垫资金额" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="借款简介" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.zdj_pz" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    
			    <el-form-item label="申请时间" >
			      <el-input v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="放款时间" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.qcys" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="实际放款金额" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.zdj_pz" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="电子合同地址" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.zdj_pz" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    <el-form-item label="失败理由" >
			      <el-input type="textarea" :rows=3 v-model="dialogForm.zdj_pz" auto-complete="off" disabled></el-input>
			    </el-form-item>
			    
			    <el-form-item label="操作人" >
			      <el-input v-model="dialogForm.zdj_pz" auto-complete="off" disabled></el-input>
			    </el-form-item>
			</div>
		</el-card>
		<div style="text-align:right;margin-top:15px;">
			 <el-button @click="returnBack">返 回</el-button>
			 <el-button v-if="dialogSendData.isAdd" type="primary" @click="submitConfirmForm('dialogForm')">提 交</el-button>
		</div>
		</el-form>
	</div>
</template>
<script>
    import agentHttp from '@/utils/agentHttp.js'
	export default{
		components:{},
		created(){		
			if(this.dialogSendData.id!==""){
	      		//修改
	      		this.selectData(); 
	      	}
        },
        
        updated(){
        },
		props:['dialogSendData','tableData'],
		data(){
			return{
				
				formLabelWidth:'170px',
				//弹窗或者查看页面信息
		         dialogForm:{
		          imagUrl:[],   //七牛图片地址
		          activityTheme:"",
		          linkUrl:""
		         
		        },
		        //验证规则
		        rules: {
		        }
			}
		},methods:{
			returnBack(){
				this.dialogSendData.dialogFormVisible=false;
			},
			submitConfirmForm(formName){
                this.$refs[formName].validate((valid) => {
		          if (valid) {
		          	if(this.dialogSendData.id===""){
		          		//添加
		          	    this.addData();
		          	}else{
		          		//修改
		          		this.editData();
		          	}
		          	setTimeout(()=>{
	            		this.dialogSendData.dialogFormVisible=false;
	            	},500)
		          } else {
		            this.$nextTick(()=>{
		          		this.$message.warning(document.getElementsByClassName('el-form-item__error')[0].innerText||"提交失败");
		                return false;
		          	})
		          }
		        });
			},
		    addData(){
		        this.dialogForm.imagUrl=this.qiniuImage.image_uri.join(",")
		        agentHttp.postJson('adminApi/admin/carousel/post_validated',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData', null);
		            	this.$message.success(data.data||"添加成功");
		            } 
		        }) 
		    },
		    editData(){
		    	this.dialogForm.imagUrl=this.qiniuImage.image_uri.join(",")
		        agentHttp.putJson('adminApi/admin/carousel/put_validated',this.dialogForm).then((data)=>{
		            if(data.success){  
		            	this.$emit('refreshTableData', null);
		            	this.$message.success(data.data||"修改成功");
		            } 
		        }) 
		    },
		    selectData(){
		    	//console.log('取消下方注释，修改请求地址')
		        agentHttp.get('adminApi/admin/carousel/select_carousel/'+this.dialogSendData.id).then((data)=>{	
		            if(data.success){  
		            	this.dialogForm=data.data;
		            	this.qiniuImage.image_uri=data.data.imagUrl.split(',').notempty()//去掉为空的项，不然导致图片张数控制不准
		            } 
		        }) 
		    },

		}
	}
</script>